package com.wyw.learning.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Title
 * @Description 三个接口均没在Spring Security中放开
 * @Author Mr Wu yewen.wu.china@gmail.com
 * @Date 2023/9/15 13:59
 * Update History:
 * Author        Time            Content
 */
@RestController
public class MessagesController {

    /**
     * 仅需要accessToken
     */
    @GetMapping("/messages1")
    public String getMessages1() {
        return " hello Message 1";
    }

    /**
     * 需要accessToken和拥有profile权限
     */
    @GetMapping("/messages2")
    @PreAuthorize("hasAuthority('SCOPE_profile')")
    public String getMessages2() {
        return " hello Message 2";
    }

    /**
     * 需要accessToken和拥有Message权限
     */
    @GetMapping("/messages3")
    @PreAuthorize("hasAuthority('SCOPE_Message')")
    public String getMessages3() {
        return " hello Message 3";
    }

}
